﻿Imports Microsoft.DirectX
Public Class LandschaftstexturBruecke
    Inherits ObjektLandschaftsTextur
    ''' <summary>
    ''' 0=   1=+N   2=+N+O   3=+N+S   4=+N+O+S   5=+N+O+S+W
    ''' </summary>
    ''' <remarks></remarks>
    Dim UebergangsMeshs(5) As Objekt3D


    Public Sub New()
        ID = "BRUECKE"
        Landschaftsname = "Bruecke"
        Deckung = 0
        Tarnung = False
        KP = -1
        If DataSettings.draw3D Then
            TexturenLaden(New String() {"BRUECKE", "BRUECKE+N+S", "BRUECKE+O+W", "BRUECKE+N+S+W", "BRUECKE+N+O+S", "BRUECKE+N+O+S+W", "BRUECKE+N+O+W", "BRUECKE+O+S+W", "BRUECKE+W", "BRUECKE+O", "BRUECKE+S", "BRUECKE+N", "BRUECKE+S+W", "BRUECKE+O+S", "BRUECKE+N+W", "BRUECKE+N+O"})
        Else
            TexturenLaden(New String() {"BRUECKE", "BRUECKE+N+S", "BRUECKE+O+W", "BRUECKE+N+S+W", "BRUECKE+N+O+S", "BRUECKE+N+O+S+W", "BRUECKE+N+O+W", "BRUECKE+O+S+W", "BRUECKE+W", "BRUECKE+O", "BRUECKE+S", "BRUECKE+N", "BRUECKE+S+W", "BRUECKE+O+S", "BRUECKE+N+W", "BRUECKE+N+O"})
        End If


        Normal = 0
        Ausrichtungslandschaften = New String() {"FLUSS", "SEE", "RIFF", "STRAND", "SUMPF", "RAUESEE", "NEBEL"}
        Select Case DataSettings.TerrainStyle
            Case TerrainStyle.AdvanceWarsDC, TerrainStyle.CommanderWars2
                DrawUebergaenge = True
            Case Else
                DrawUebergaenge = False
        End Select

        If DataSettings.draw3D Then
            Ini3D()
        End If
    End Sub
    Public Overrides Function DrawSpecialStyle(ByVal BildID As Integer, ByVal Fog As Nebelarten, ByVal Alpha As Integer, ByVal X As Integer, ByVal Y As Integer, ByVal TerrainUntergrundID As Integer, ByVal TerrainUntergrundBildID As Integer, ByVal TerrainUntergrundID2 As Integer, ByVal TerrainUntergrundBildID2 As Integer, Optional ByVal FixedLocation As Boolean = False, Optional ByVal Top As Boolean = False) As Boolean
        Return DrawTerrainUndUntergrund(Alpha, Fog, BildID, X, Y, 0, 0, TerrainUntergrundID, TerrainUntergrundBildID, TerrainUntergrundID2, TerrainUntergrundBildID2, FixedLocation, Top)
    End Function


    Public Overrides Sub Malen3D(ByVal p_MatCube As Microsoft.DirectX.Matrix, ByVal Landschaft As ObjektLandschaft)
        'BrueckenMesh malen
        Dim ind As Integer = 0
        Dim Rot As Single = 0
        Dim Ausr As String = AusrichtungVereinfachen(AusrichtungInvertieren(getAusrichtung(Landschaft.KooX, Landschaft.KooY, Objektverwalter.Spielfeld).ToUpper), Rot)
        Select Case Ausr
            Case ""
                ind = 0
            Case "+N"
                ind = 1
            Case "+N+O"
                ind = 2
            Case "+N+S"
                ind = 3
            Case "+N+O+S"
                ind = 4
            Case "+N+O+S+W"
                ind = 5
        End Select
        Dim Mat As Matrix = Matrix.RotationY(Rot)
        Mat.M41 = p_MatCube.M41 + 0.5
        Mat.M42 = p_MatCube.M42
        Mat.M43 = p_MatCube.M43 + 0.5
        UebergangsMeshs(ind).Malen(Mat)

        'Ganz normal Wasser als untergrund malen.
        Malen3D(p_MatCube, "SEE", Landschaft)
    End Sub

    Public Overrides Sub Ini3D()
        UebergangsMeshs(0) = New Objekt3D()
        UebergangsMeshs(1) = New Objekt3D()
        UebergangsMeshs(2) = New Objekt3D()
        UebergangsMeshs(3) = New Objekt3D()
        UebergangsMeshs(4) = New Objekt3D()
        UebergangsMeshs(5) = New Objekt3D()
        UebergangsMeshs(0).MeshBildLaden(DataSettings.Resourcenpfad + "Terrain\Meshes\Bruecke.x")
        UebergangsMeshs(1).MeshBildLaden(DataSettings.Resourcenpfad + "Terrain\Meshes\Bruecke+N.x")
        UebergangsMeshs(2).MeshBildLaden(DataSettings.Resourcenpfad + "Terrain\Meshes\Bruecke+N+O.x")
        UebergangsMeshs(3).MeshBildLaden(DataSettings.Resourcenpfad + "Terrain\Meshes\Bruecke+N+S.x")
        UebergangsMeshs(4).MeshBildLaden(DataSettings.Resourcenpfad + "Terrain\Meshes\Bruecke+N+O+S.x")
        UebergangsMeshs(5).MeshBildLaden(DataSettings.Resourcenpfad + "Terrain\Meshes\Bruecke+N+O+S+W.x")
    End Sub

    Public Overrides Sub Tick()

    End Sub
    Public Overrides Function GetTerrainUntergrund() As String()
        Return New String() {"SEE", "FLUSS"}
    End Function
End Class
